<template>
	<view class="page bg-fff">
        <view class="topTit text-center">
            <u-icon name="error-circle-fill" color="#FAA000" size="70"></u-icon>
            <view class="font18 fontBold">申请注销置业顾问账号</view>
        </view>
        <view class="content">
            <view class="txt">
                请谨记：注销置业顾问账号，你将无法获得本账号《顾问之家》绑定的任何内容或信息。
            </view>
            <view class="txt">
                (1)、你将无法登录本账号的《顾问之家》。你的客户将无法通过小程序联系到你。
            </view>
            <view class="txt">
                (2)、你的置业顾问个人资料和动态信息（包含昵称、头像、二维码、专属客户、积分、活跃度、问答、动态等）视为你自行放弃，都将无法找回。
            </view>
            <view class="txt">
                (3)、在置业顾问账号注销期间，如果你的账号被他人投诉、被国家机关调查或者正处于诉讼、仲裁程序中，平台有权自行终止你的账号注销行为。
            </view>
        </view>
        <view class="cancelBtn bg-theme col-fff text-center" @click="cancellationBtn">申请注销</view>
	</view>
</template>
<script>
    import { mapActions } from 'pinia';
    import { useUserInfoStore, useIndexStore } from '@/store/index';
	import { getUserInfo } from '@/common/api/user';
    // import { cancellationAPI } from '@/common/api-adviser';
    import { getCurrentUserInfo } from '@/common/api/chat';

	export default {
		data() {
			return {
                adviserId: ''
			}
		},
		onLoad(options){
            let { adviserId } = options;
            this.adviserId = adviserId;
		},
		methods: {
			...mapActions(useUserInfoStore, ['setUserInfo']),
            ...mapActions(useIndexStore, ['setAdviserCardData']),

			cancellationBtn(){
                const that = this;
                uni.showModal({
                    title: '提示',
                    content: '确定要注销置业顾问吗?',
                    success: async (res) => {
                        if (res.confirm) {
                            try {
                                const userInfoRes = await getUserInfo();
                                const chatUserInfo = await getCurrentUserInfo();
                                
                                if(userInfoRes.status === 0){
                                    that.setUserInfo(userInfoRes.detail);
                                    uni.setStorage({
                                        key: 'userInfo',
                                        data: userInfoRes.detail
                                    })
                                }

                                if(chatUserInfo.status === 0) {
                                    that.setCurrChatUser(chatUserInfo.detail);
                                }
                            } catch (error) {
                            }

                            // cancellationAPI().then(res => {
                            //     if(res.status !== 0) {
                            //         uni.$u.toast(res.detail);
                            //         return
                            //     }
                            //     uni.switchTab({
                            //         url: '/pages/tabBar/my/index'
                            //     })
                            // })
                        }
                    }
                })
            }
		}
	}
</script>

<style lang="scss" scoped>
	.page{
        min-height: 100vh;
        overflow: hidden;
        padding: 30rpx;
        .topTit{
            margin-top: 20rpx;
        }
        .content{
            .txt{
                margin-top: 20rpx;
            }
        }
        .cancelBtn{
            margin-top: 50rpx;
            height: 80rpx;
            line-height: 80rpx;
            border-radius: 10rpx;
        }
    }
</style>
